package com.hgl.bi.common.exception;

import com.hgl.bi.common.constant.ErrorCode;
import lombok.Getter;

/**
 * @program: BI
 * @description: 业务异常
 * @author: hgl
 * @create: 2025-02-09 16:56
 */
@Getter
public class BusinessException extends RuntimeException {

    private final Integer code;

    /**
     * 有参构造方法
     *
     * @param code    错误码
     * @param message 错误信息
     * @author hgl
     */
    public BusinessException(Integer code, String message) {
        super(message);
        this.code = code;
    }

    /**
     * 枚举有参构造方法
     *
     * @param errorCode 错误码
     * @author hgl
     */
    public BusinessException(ErrorCode errorCode) {
        super(errorCode.getMessage());
        this.code = errorCode.getCode();
    }
}
